/*
 * @Descripttion: 
 * @version: 
 * @Author: Jun
 * @Date: 2021-05-24 14:20:33
 * @LastEditors: Jun
 * @LastEditTime: 2021-05-29 16:16:52
 */
import Vue from "vue"
import VueRouter from "vue-router"
import { routes } from "./commonRoutes.js"

Vue.use(VueRouter)

let router = new VueRouter({
    routes,
    mode: 'history',
})

//全局前置路由拦截
router.beforeEach((to, from, next) => {
    if(to.meta.interceptors){
        next()
    }else{
        if(!localStorage.getItem("zunyi_pc_token")){//没有token
            next({path:'/'})//回登录页
        }else{//有token
            // next({path:to.path,query:to.query})
            next()
        }
    }
})

export default router